****The Stata commands included in this do file were used to impose a linear progression on state populations for congresses occuring between decenial censuses prior to the availability of annual population data by state in 1900. Doing so requires that results be repeatedly saved and appended by congress, eventually producing a dataset entitled popestimates.dta, which includes the congress-by-congress estimates, 1789-1901. In certain cases, additional adjustments were necessary because of limitations to 18th and 19th Century Census figures, and explanations are commented out and accompany commands for the relevant congress.

use "population_decennial_pre1901.dta"
gen congress=1
keep if cenyear==1790
gen popest = totalpop
* the next command adjusts the Virginia population estimate to include the estimate for Kentucky
replace popest = popest + 73677 if state_icpsr==40
keep cenyear state_icpsr totalpop popest congress
save "popestimates.dta"
clear

use "population_decennial_pre1901.dta"
gen congress=2
keep if cenyear==1790
gen popest=.8*totalpop + .2*nextpop
* the next command adjusts the Virginia population estimate to include the estimate for Kentucky
replace popest = popest + 103132.6 if state_icpsr==40
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=3
keep if cenyear==1790
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=4
keep if cenyear==1790
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=5
keep if cenyear==1790
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=6
keep if cenyear==1800
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=7
keep if cenyear==1800
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=8
keep if cenyear==1800
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=9
keep if cenyear==1800
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=10
keep if cenyear==1800
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=11
keep if cenyear==1810
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=12
keep if cenyear==1810
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=13
keep if cenyear==1810
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=14
keep if cenyear==1810
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=15
keep if cenyear==1810
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=16
keep if cenyear==1820
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=17
keep if cenyear==1820
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=18
keep if cenyear==1820
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=19
keep if cenyear==1820
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=20
keep if cenyear==1820
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=21
keep if cenyear==1830
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=22
keep if cenyear==1830
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=23
keep if cenyear==1830
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=24
keep if cenyear==1830
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=25
keep if cenyear==1830
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=26
keep if cenyear==1840
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=27
keep if cenyear==1840
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=28
keep if cenyear==1840
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=29
keep if cenyear==1840
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=30
keep if cenyear==1840
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=31
keep if cenyear==1850
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=32
keep if cenyear==1850
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=33
keep if cenyear==1850
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=34
keep if cenyear==1850
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=35
keep if cenyear==1850
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=36
keep if cenyear==1860
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=37
keep if cenyear==1860
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=38
keep if cenyear==1860
gen popest=.6*totalpop + .4*nextpop
* the next command adjusts the Virginia population estimate to excluded the estimate for West Virginia.
replace popest=popest - 402818.4 if state_icpsr==40
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=39
keep if cenyear==1860
gen popest=.4*totalpop + .6*nextpop
* the next command adjusts the Virginia population estimate to exclude the estimate for West Virginia. The adjustment is included only for purposes of consistency. It is dropped below because Virginia was not represented in the Senate during this congress.
replace popest=popest - 415883.6 if state_icpsr==40
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=40
keep if cenyear==1860
gen popest=.2*totalpop + .8*nextpop
* the next command adjusts the Virginia population estimate to exclude the estimate for West Virginia. The adjustment is included only for purposes of consistency. It is dropped below because Virginia was not represented in the Senate during this congress.
replace popest=popest - 428948.8 if state_icpsr==40
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=41
keep if cenyear==1870
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=42
keep if cenyear==1870
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=43
keep if cenyear==1870
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=44
keep if cenyear==1870
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=45
keep if cenyear==1870
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=46
keep if cenyear==1880
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=47
keep if cenyear==1880
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=48
keep if cenyear==1880
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=49
keep if cenyear==1880
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=50
keep if cenyear==1880
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=51
keep if cenyear==1890
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=52
keep if cenyear==1890
gen popest=.8*totalpop + .2*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=53
keep if cenyear==1890
gen popest=.6*totalpop + .4*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=54
keep if cenyear==1890
gen popest=.4*totalpop + .6*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=55
keep if cenyear==1890
gen popest=.2*totalpop + .8*nextpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace
clear

use "population_decennial_pre1901.dta"
gen congress=56
keep if cenyear==1900
gen popest = totalpop
keep cenyear state_icpsr totalpop popest congress

append using "popestimates.dta"
save "popestimates.dta", replace

clear

*The purpose of the next set of commands is to strip out states that were not formally part of the Union during a particular congress and thus did not have Senators represented in the roll call record.
use "votes.dta"
keep if congress < 57
duplicates drop congress state_icpsr, force
keep congress state_icpsr
merge 1:1 congress state_icpsr using "popestimates.dta"
keep if _merge==3
drop _merge
keep congress state_icpsr popest
rename popest population
save "popestimates.dta", replace

